var mysql = require('mysql')

var connection  = mysql.createConnection({
    host:'localhost',
    user:"root",
    password:"123",
    database:"vue"
});

connection.connect();

function Status(status){
    this.insertStatus= status.insertStatus;
    this.queryStatus= status.queryStatus;
    this.deleteStatus = status.deleteStatus;
    this.updateStatus = status.updateStatus;
}
Status.prototype.query = function(sqlStr,callback){
    if(!this.queryStatus){
        return;
    }
    connection.query(sqlStr,function(error,results,fields){
        if(error)  throw error;
       callback(results)
    })
}

Status.prototype.insert  = function(sqlStr,callback){
    if(!this.insertStatus){
        return;
    }
    connection.query(sqlStr,function(error,results,fields){
        if(error)  throw error;


       
        callback(results[1].time)
        var message = 0;
       

    })
}



var stock  =new Status({
    insertStatus:true,
    deleteStatus:false,
    updateStatus:false,
    queryStatus:true
})

var sqlStrr = 'select * from newsList where id = 1';
stock.query('select * from newsList',function(resultss){
    console.log(resultss[0].id)
})





